<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    {{template "link/customer/link.html" . }}
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <style>
        .item-head {
            height: 80px;
            border: 1px solid #e2e2e2;
            background: #eaf8ff;
        }

        .order-item {
            margin-bottom: 30px;
        }

        .head-item {
            margin-right: 100px;
        }

        .head-item-left {
            float: left;
        }

        .head-item-right {
            float: right;
        }
    </style>
</head>
<body>

<div>
    <ul class="layui-nav">
        <li class="layui-nav-item"><a href="">店铺:{{.Store.StoresName}}</a></li>
        <li class="layui-nav-item "><a href="/sell/index">店铺主页</a></li>
        <li class="layui-nav-item layui-this"><a href="/sell/orderList">订单</a></li>
        <li class="layui-nav-item "><a href="/sell/store/manage">店铺管理</a></li>
        <li class="layui-nav-item"><a href="/sell/goodManage">商品管理</a></li>
        <li class="layui-nav-item"><a href="/sell/kindManage">种类管理</a></li>
        <li class="layui-nav-item"><a href="/sell/logout">退出</a></li>
    </ul>
</div>
<div class="content content-nav-base shopcart-content">

    <div class="cart w1200">
        <div class="cart-table-th">
            <div class="th th-item">
                <div class="th-inner">
                    商品
                </div>
            </div>
            <div class="th th-price">
                <div class="th-inner">
                    单价
                </div>
            </div>
            <div class="th th-amount">
                <div class="th-inner">
                    数量
                </div>
            </div>
            <div class="th th-sum">
                <div class="th-inner">
                    实付款
                </div>
            </div>
            <div class="th th-sum">
                <div class="th-inner">
                    状态
                </div>
            </div>
        </div>
        <div class="OrderList">
            {{range .Orders}}
                <div class="order-content order-item" id="list-cont">
                    <div class="item-head">
                        <div style="height: 20px">
                            <div class="head-item-left">
                                <span class="head-item"> 下单时间 {{.OrderCreateTime}} </span>
                                <span class="head-item">订 单 号 {{.OrderId}}</span>
                            </div>
                            <div class="head-item-right">
                                <span class="head-item">总价 : {{.OrderSumPrices}}</span>
                            </div>
                        </div>
                        <div style="height: 25px; margin: 5px 0;">
                            <div class="head-item-left">
                                <span class="head-item"> 联系人 {{.OrderUserName}} </span>
                            </div>
                            <div class="head-item-right">
                                <span class="head-item"> 联系人电话 {{.OrderUserPhone}}</span>
                            </div>
                        </div>
                        <div style="height: 25px;">
                            <div class="head-item-left">
                                <span>送往{{.OrderProvince }}  {{.OrderCity}} {{.OrderArea}}  {{.OrderAddress}}</span>
                            </div>
                            <div class="head-item-right">
                                {{if eq .OrderStatus "已下单"}}
                                    <button style="height: 24px;line-height: 0px;"
                                            class="layui-btn layui-btn-danger"
                                            value="{{.OrderId}}" id="confirm-send">确认发货
                                    </button>
                                {{else}}
                                    <span style="color: red;margin-right: 120px">{{.OrderStatus}}</span>
                                {{end}}
                            </div>
                        </div>
                    </div>
                    {{$orderStatus := .OrderStatus}}
                    {{range .OrderItems}}
                        <div>
                            <ul class="item-content layui-clear">
                                <li class="th th-item">
                                    <div class="item-cont">
                                        <a href="/sell/good?id={{.ItemGoodsId}}"><img
                                                    src="/static/upload/good/{{.GoodItem.GoodUrl}}" alt=""></a>
                                        <div class="text">
                                            <div class="title">{{.GoodItem.GoodName}}</div>
                                        </div>
                                    </div>
                                </li>
                                <li class="th th-price">
                                    <span class="th-su">{{.ItemPrices}}</span>
                                </li>
                                <li class="th th-amount">
                                    <div class="box-btn layui-clear">
                                        <input type="text" hidden="hidden" value="{{.GoodItem.GoodId}}" class="goodId">
                                        <input class="Quantity-input" type="" name="" value="{{.ItemNums}}"
                                               disabled="disabled">
                                    </div>
                                </li>
                                <li class="th th-sum">
                                    <span class="sum">{{.ItemSum}}</span>
                                </li>
                                <li class="th th-price">
                                    <span class="sum">{{$orderStatus}}</span>
                                </li>
                            </ul>
                        </div>
                    {{end}}
                </div>
            {{end}}

        </div>

    </div>
</div>

<script type="text/javascript">
    layui.config({
        base: '/static/js/util/' //你存放新模块的目录，注意，不是layui的模块目录
    }).use(['mm', 'jquery', 'element', 'car','layer'], function () {
            var $ = layui.jquery
            var layer = layui.layer
            $("#confirm-send").on('click',function () {
                    var orderId = $(this).val()
                    var item = "orderId="+orderId
                    layer.open({
                        content:'确认发货',
                        yes:function () {
                            $.ajax({
                                    url: "/sell/sendOrder",
                                    method: 'post',
                                    data: item,
                                    dataType: 'json',
                                    contentType: "application/x-www-form-urlencoded;charset=UTF-8",
                                    success: function (res) {
                                        console.log(res);
                                        if (res.code == 0) {
                                            layer.alert("已发货")
                                        } else {
                                            layer.alert("失败")
                                        }
                                    }
                                }
                            )
                        }
                    })
            });
    });
</script>
</body>
</html>